RWTH - Mindstorms NXT Toolbox

GetAccelerator

Reads the current value of the HiTechnic acceleration sensor

Contents

Syntax

acc_vector = GetAccelerator(port)

acc_vector = GetAccelerator(port, handle)

Description

acc_vector = GetAccelerator(port) returns the current 1x3 accelerator vector acc_vector of the HiTechnic acceleration sensor. The column vector contains the readings of the x, y, and z-axis, respectively. A reading of 200 is equal to the acceleration of 1g. Maximum range is -2g to +2g. The given port number specifies the connection port. The value port can be addressed by the symbolic constants SENSOR_1 , SENSOR_2, SENSOR_3 and SENSOR_4 analog to the labeling on the NXT Brick.

The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).

Example

   OpenAccelerator(SENSOR_4);
   acc_Vector = GetAccelerator(SENSOR_4);
   CloseSensor(SENSOR_4);

See also

OpenAccelerator, CloseSensor, COM_ReadI2C

Signature